package com.tailyou.androidlearning202400

import android.graphics.Color
import android.os.Bundle
import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.View
import android.widget.CheckBox
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class XXTLoginActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        this.enableEdgeToEdge()
        setContentView(R.layout.activity_login_xxt)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v: View, insets: WindowInsetsCompat ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        val cbAgree = findViewById<CheckBox>(R.id.cbAgree)
        // 设置部分文字显示不同颜色
        val ss = SpannableString("我已阅读并同意学习通《隐私政策》和《用户协议》")
        ss.setSpan(
            ForegroundColorSpan(Color.parseColor("#0E8BAF")),
            10,
            16,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        ss.setSpan(
            ForegroundColorSpan(Color.parseColor("#0E8BAF")),
            17,
            23,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        cbAgree.text = ss
    }
}